<%@ page import="cn.school.service.StudentService" %>
<%@ page import="cn.school.entity.Student" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: ghost
  Date: 2019/12/8
  Time: 18:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>学生信息</title>
    <style>
      a{
        text-decoration: none;
      }
    </style>
  </head>
  <body>
  <%@include file="checkLogin.jsp"%>
  <p>欢迎你，<%=o%>&nbsp;<a onclick="return window.confirm('确认退出登录？');" href="loginout.jsp">注销</a></p>
  <p><a href="subjectinfo.jsp">课程信息</a></p>
  <table border="1" cellspacing="0" cellpadding="10">
    <tr><td>姓名</td><td>性别</td><td>电话号码</td><td>qq</td><td>微信</td><td>所在班级</td><td>操作</td></tr>
<%
  int pageNo = (int) session.getAttribute("pageNo");
  StudentService ss = new StudentService();
  List<Student> list = ss.search(pageNo,10,null,null,null,null);
  for(Student s:list){
%>
    <tr><td><%=s.getSname()%></td><td><%=s.getSex()%></td><td><%=s.getTelephone()%></td>
      <td><%
        if(s.getQq()!=null){
            out.print(s.getQq());
        }else{
            out.print("");
        }
        %>
      </td><td><%=s.getWechat()%></td><td><%=s.getGname()%></td><td><a href="alterStudent.jsp?id=<%=s.getStuno()%>">修改</a>&nbsp;
        <a onclick="return window.confirm('确认删除？')" href="delstu.jsp?id=<%=s.getStuno()%>">删除</a></td></tr>
<%
  }
%>
  </table>
  <br/>
  <%
    Integer count= ss.countStu()/10;
    if(pageNo != 1){
      out.print("<a href='changeLimit.jsp?pageNo=0'>上一页</a>");
    }
    for(int i=1;i<=count;i++){
        if(i == pageNo){
            out.print("\t第"+i+"页\t");
        }else{
            out.print("<a href='changeLimit.jsp?pageNo="+i+"'>\t第"+i+"页\t</a>");
        }
    }
    if(pageNo != count){
      out.print("<a href='changeLimit.jsp?pageNo=-1'>下一页</a>");
    }
  %>
  </body>
</html>
